<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <!--<meta name="csrf-token" content="{{ csrf_token() }}" />-->
    <meta http-equiv="expires" content="0"> 
	<title>登录界面</title>
    <link href="/home/css/css/default.css" rel="stylesheet" type="text/css" />
	<!--必要样式-->
    <link href="/home/css/css/styles.css" rel="stylesheet" type="text/css" />
    <link href="/home/css/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/home/css/css/loaders.css" rel="stylesheet" type="text/css" />
    <style>
    	input {
    		border: 0 none;
    		color: #000000;
    		width: 88px;
    		height: 30px;
    		font-size: 18px;
    		margin: 3px;
    	}
    		
    	input[type="button"] {
    		cursor: pointer;	
    	}
    	    	
    	.aaaa {
    		height: 40px;
    		margin: 2px 0;
    		overflow: hidden;
    	}
    	
    	.aaa {
    		height: 40px;
    		margin: 2px 0;


    	}
    	
    	
    	.aa {
    		height: 40px;
    	}
    	
    	.login {
    		margin-top: -100px;
    		height: 800px;
    	}
    </style>
</head>
<body>
	<div class='login'>
	@if(Auth::guard('member')->user()->avatar != '')
	 <img src="{{Auth::guard('member')->user()->avatar}}" alt="" style="display:block;margin:0 auto;border-radius:50%" width="100" height="100" />
	@else
	<img src="/admin/avatar/avatar.jpg" alt="" style="display:block;margin:0 auto;border-radius:50%" width="100" height="100" />
	@endif
	 <h1 style="margin-top:10px;text-align:center;">密码修改</h1> 
	 <form action="" method="post">
	 <div class="aaaa">用户名：
	 	<input type="text" name="username" value="{{Auth::guard('member')->user()->username}}" readonly style="background:#ccc;"/>
	 </div>
	 <div class="aaaa">密　码：
	 	<input type="password" name="password" placeholder="密码" />
	 </div>
	 <div class="aaaa">密　码：
	 	<input type="password" name="password2" placeholder="再次输入密码" />
	 	<input type="hidden" name="id" value="{{Auth::guard('member')->user()->id}}" />
	 </div>
	 <div class="aaa">验证码：
	 	<input type="hidden" name="email" value="{{Auth::guard('member')->user()->email}}" style="width:30px;"/>
	 	<input type="text" id="code" name="code" />
	 	<input type="button" onclick="send(this)" value="获取邮箱验证码" class="aa"></input>
	 </div>
	 {{csrf_field()}}
	 <input type="button" value="提交" class="btnl" /><a href="/" style="margin-left:5px;" >返回首页</a>
	 </form>
	 
	 <style>
	 	a {
	 		display: inline-block;
	 		height: 40px;
	 		line-height: 40px;
	 		border-radius: 4px;
	 		margin: 0;
	 		padding: 0;
	 		color: #fff;
			text-decoration: none;
			font-weight: bold;
			background: rgba(255,255,255,.5);
	 	}
	 </style>
	</div>
	<div class="OverWindows"></div>
    <link href="/home/layui/css/layui.css" rel="stylesheet" type="text/css" />
	<script src="/home/js/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="/home/js/js/jquery-ui.min.js"></script>
	<script type="text/javascript" src='/home/js/js/stopExecutionOnTimeout.js?t=1'></script>
    <script src="/home/layui/layui.js" type="text/javascript"></script>
    <script src="/home/js/js/Particleground.js" type="text/javascript"></script>
    <script src="/home/js/js/Treatment.js" type="text/javascript"></script>
    <script src="/home/js/js/jquery.mockjax.js" type="text/javascript"></script>
    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript">
		
		
		var time = 60;
        function send(_this) {
            //发送ajax
            var email = $('input[name=email]').val();
            // console.log(mobile);
            //一次倒计时发送一次短信
            if(time == 60) {
                $.ajax({
                    headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' },
                    type: 'post',
                    url: '/home/member/mailTest',
                    data: {email: email},
                    dataType: 'json',
                    success: function(data){
                        /*if(data.error_code == '1'){
                            layer.alert('发送成功');
                        }else{
                            layer.alert('发送失败');
                        }*/
                  

                    }
                });
            }
            
            if(time == 0){
                _this.removeAttribute("disabled");
                _this.value = "获取短信验证码";
                time = 60;
                return;
            }else{
                _this.setAttribute("disabled",true);
                _this.value = "重新发送(" + time + "s)";
                time--;
            }
            //定时器
            setTimeout(function(){
                send(_this);
            },1000);
        }
		
		
		
		$('.btnl').click(function (e) {
			
			id = $('input[name=id]').val();
			password = $('input[name=password]').val();
			password2 = $('input[name=password2]').val();
			code = $('input[name=code]').val();
			$.ajax({
				headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' },
				url:'/home/member/editPassword',
				type:'post', 
				data:{id:id,password:password,password2:password2,code:code},
				success:function(data) {
					console.log(data);
					if(data == '1') {
						
						alert('修改成功');
						location.href="/";
						
					}else {
						alert('密码不一致或验证码错误');
					}
				}
				
			});
			
			e.preventDefault();

		});
		

	
    </script>
</body>
</html>
